# -------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#
# -------------------------------------------------------------

# Autogenerated By   : src/main/python/generator/generator.py
# Autogenerated From : scripts/builtin/img_crop_linearized.dml

from typing import Dict, Iterable

from systemds.operator import OperationNode, Matrix, Frame, List, MultiReturn, Scalar
from systemds.utils.consts import VALID_INPUT_TYPES


def img_crop_linearized(img_in: Matrix,
                        w: int,
                        h: int,
                        x_offset: int,
                        y_offset: int,
                        s_cols: int,
                        s_rows: int):
    """
     The img_crop_linearized cuts out a rectangular section of multiple linearized images.
    
     .. code-block:: python
    
       >>> import numpy as np
       >>> from systemds.context import SystemDSContext
       >>> from systemds.operator.algorithm import img_crop_linearized
       >>> 
       >>> with SystemDSContext() as sds:
       ...     img = sds.from_numpy(
       ...         np.array([[ 50., 100., 150.,
       ...                     150., 200., 250.,
       ...                     250., 200., 200. ]], dtype=np.float32)
       ...     )
       ...     result_img = img_crop_linearized(img, 1, 1, 1, 1, 3, 3).compute()
       ...     print(result_img)
       [[200.]]
    
    
    
    
    :param img_in: Input images as linearized 2D matrix with top left corner at [1, 1] (every row represents a linearized matrix/image)
    :param w: The width of the subregion required
    :param h: The height of the subregion required
    :param x_offset: The horizontal offset for the center of the crop region
    :param y_offset: The vertical offset for the center of the crop region
    :param s_cols: Width of a single image
    :param s_rows: Height of a single image
    :return: Cropped images as linearized 2D matrix
    """

    params_dict = {'img_in': img_in, 'w': w, 'h': h, 'x_offset': x_offset, 'y_offset': y_offset, 's_cols': s_cols, 's_rows': s_rows}
    return Matrix(img_in.sds_context,
        'img_crop_linearized',
        named_input_nodes=params_dict)
